const mongoose = require('mongoose')

const carouselSchema = new mongoose.Schema(
  {
    fileId: {
      type: String,
      default: function () {
        return this._id.toString()
      }
    },
    filePath: { type: String, required: true },
    fileName: { type: String, required: true },
    order: {
      type: Number,
      required: true,
      default: 0
    },
    createdAt: {
      type: Date,
      default: Date.now
    }
  },
  { timestamps: true }
)
carouselSchema.index({ fileId: 1 })

module.exports = mongoose.model('Carousel', carouselSchema)
